import 'package:flutter/material.dart';
import 'package:hkzf_flutter/widgets/information/data.dart';
import 'package:hkzf_flutter/widgets/information/item_widget.dart';

// 资讯面板区域
class InformationPanel extends StatelessWidget {
  final bool showTitle;// 是否展示标题文字
  final List<InformationItem> dataList;//  数据列表
  InformationPanel({super.key, bool? showTitle,List<InformationItem>? dataList }):showTitle = showTitle ?? false, dataList = dataList ?? informationData;
 
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          if(showTitle) Container(
            padding: const EdgeInsets.all(10.0),
            alignment: Alignment.centerLeft,
            child: const Text("最新资讯", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold),),
          ),
          Column(
            children: dataList.map((item)=>InkWell(// 通过InkWell监听点击事件，水波纹点击反馈效果
              onTap: () => {
                Navigator.of(context).pushNamed(item.navigateUri)
              },
              child: Container(
                margin: const EdgeInsets.only(bottom: 10.0),
                child: InformationItemWidget(data: item),
              ),
            )).toList(),
          )

        ],
      ),
    );
  }
}